package main

import (
	workpool "go-workerpool/pool"
	"time"
)

func main() {
	// 创建线程池
	pool := workpool.New(5)

	// 提交 10 个任务给线程池
	for i := 0; i < 10; i++ {
		err := pool.Schedule(func() {
			time.Sleep(time.Second * 3)
		})
		if err != nil {
			println("task: ", i, "err:", err)
		}
	}
	// 线程池停止
	pool.Free()
}
